Skip to content

Add raw STS error code to MsalFailure metric#5961

Merged
ssmelov merged 12 commits intomainfrom
feature/add_sts_raw_error_code_to_msalfailure_metric
Apr 30, 2026
Merged

Add raw STS error code to MsalFailure metric#5961
ssmelov merged 12 commits intomainfrom
feature/add_sts_raw_error_code_to_msalfailure_metric

Conversation

@ssmelov
Copy link
Copy Markdown
Collaborator

@ssmelov ssmelov commented Apr 29, 2026

Adds a RawStsErrorCode tag to the MsalFailure OpenTelemetry counter to surface the raw ESTS error code emitted by the identity provider (error_codes array).

Copilot AI review requested due to automatic review settings April 29, 2026 13:43
@ssmelov ssmelov requested a review from a team as a code owner April 29, 2026 13:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new OpenTelemetry tag on the MsalFailure counter to surface the raw ESTS error_codes value from MsalServiceException.ErrorCodes, and updates unit tests to validate presence/absence of the tag.

Changes:

  • Add TelemetryConstants.RawStsErrorCode tag name and plumb a rawStsErrorCode argument through the OTel instrumentation interface/call sites.
  • Emit RawStsErrorCode on MsalFailure only when a non-empty raw STS error code is available.
  • Add unit tests verifying the tag is included for MsalServiceException and not included for MsalClientException.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Microsoft.Identity.Test.Unit/TelemetryTests/OTelInstrumentationTests.cs Adds new tests for RawStsErrorCode tag behavior on MsalFailure.
src/client/Microsoft.Identity.Client/TelemetryCore/TelemetryConstants.cs Introduces RawStsErrorCode telemetry tag constant.
src/client/Microsoft.Identity.Client/TelemetryCore/OpenTelemetry/NullOtelInstrumentation.cs Extends failure logging signature to accept optional raw STS error code.
src/client/Microsoft.Identity.Client/TelemetryCore/OpenTelemetry/IOtelInstrumentation.cs Extends interface to accept optional raw STS error code.
src/client/Microsoft.Identity.Client/Platforms/Features/OpenTelemetry/OtelInstrumentation.cs Conditionally adds RawStsErrorCode tag to MsalFailure metric.
src/client/Microsoft.Identity.Client/Internal/Requests/SilentRequestHelper.cs Passes first STS error code into failure metrics for proactive refresh failures.
src/client/Microsoft.Identity.Client/Internal/Requests/RequestBase.cs Passes first STS error code into failure metrics for general request failures.

Copilot AI review requested due to automatic review settings April 30, 2026 07:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@ssmelov ssmelov merged commit 0cd8e32 into main Apr 30, 2026
19 checks passed
@ssmelov ssmelov deleted the feature/add_sts_raw_error_code_to_msalfailure_metric branch April 30, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants